<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" xmlns:shiro="http://www.pollix.at/thymeleaf/shiro">
<head>
    <th:block th:include="include :: header('评价结果列表')" />
    <th:block th:include="include :: datetimepicker-css" />
</head>
<body class="gray-bg">
     <div class="container-div">
        <div class="row">
            <div class="col-sm-12 search-collapse">
                <form id="formId">
                    <div class="select-list">
                        <ul>
                            <li>
                                <label>年份：</label>
                                <input type="text" name="year" data-type="date" data-format="yyyy"/>
                            </li>
                            <li>
                                <label>任务名称：</label>
                                <input type="text" name="taskName"/>
                            </li>
                            <li>
                                <label>合约方：</label>
                                <input type="text" name="targetName"/>
                            </li>
                            <li>
                                <label>合约方类型：</label>
                                <select name="targetClass" th:with="type=${@dict.getType('contract_party_type')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <label>评级：</label>
                                <select name="rating" th:with="type=${@dict.getType('credit_rating')}">
                                    <option value="">所有</option>
                                    <option th:each="dict : ${type}" th:text="${dict.dictLabel}" th:value="${dict.dictValue}"></option>
                                </select>
                            </li>
                            <li>
                                <a class="btn btn-primary btn-rounded btn-sm" onclick="$.table.search()"><i class="fa fa-search"></i>&nbsp;搜索</a>
                                <a class="btn btn-warning btn-rounded btn-sm" onclick="$.form.reset()"><i class="fa fa-refresh"></i>&nbsp;重置</a>
                            </li>
                        </ul>
                    </div>
                </form>
            </div>

            <!--<div class="btn-group-sm" id="toolbar" role="group">
                <a class="btn btn-success" onclick="$.operate.add()" shiro:hasPermission="credit:taskResult:add">
                    <i class="fa fa-plus"></i> 添加
                </a>
                <a class="btn btn-primary single disabled" onclick="$.operate.edit()" shiro:hasPermission="credit:taskResult:edit">
                    <i class="fa fa-edit"></i> 修改
                </a>
                <a class="btn btn-danger multiple disabled" onclick="$.operate.removeAll()" shiro:hasPermission="credit:taskResult:remove">
                    <i class="fa fa-remove"></i> 删除
                </a>
                <a class="btn btn-warning" onclick="$.table.exportExcel()" shiro:hasPermission="credit:taskResult:export">
                    <i class="fa fa-download"></i> 导出
                </a>
            </div>-->
            <div class="col-sm-12 select-table table-striped">
                <table id="bootstrap-table"></table>
            </div>
        </div>
    </div>
    <th:block th:include="include :: footer" />
    <th:block th:include="include :: datetimepicker-js" />
    <script th:inline="javascript">
        var editFlag = [[${@permission.hasPermi('credit:taskResult:edit')}]];
        var removeFlag = [[${@permission.hasPermi('credit:taskResult:remove')}]];
        var targetClassDatas = [[${@dict.getType('contract_party_type')}]];
        var ratingDatas = [[${@dict.getType('credit_rating')}]];
        var prefix = ctx + "credit/taskResult";

        //日期控件
        $("input[name='year']").datetimepicker({
            language:'zh-cn',
            format: 'yyyy',
            autoclose: true,
            todayBtn: false,
            todayHighlight: true,
            startView: 'decade',
            minView:'decade',
            maxView:'decade',
        });

        $(function() {
            var options = {
                url: prefix + "/list",
                createUrl: prefix + "/add",
                updateUrl: prefix + "/edit/{id}",
                detailUrl: prefix + "/detail/{id}",
                removeUrl: prefix + "/remove",
                exportUrl: prefix + "/export",
                modalName: "评价结果",
                columns: [{
                    checkbox: true
                },
                {
                    field: 'taskResuletId',
                    title: '评价结果id',
                    visible: false
                },
                {
                    field: 'year',
                    title: '年份'
                },
                {
                    field: 'taskName',
                    title: '任务名称'
                },
                {
                    field: 'targetClass',
                    title: '合约方类型',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(targetClassDatas, value);
                    }
                },
                {
                    field: 'targetName',
                    title: '合约方名称'
                },

                {
                    field: 'score',
                    title: '评分',
                    formatter: function(value, item, index) {
                        if (value > 89) {
                            return '<span class="label label-success">'+value+'</span>';
                        }
                        else if (value > 74) {
                            return '<span class="label label-info">'+value+'</span>';
                        }
                        else if (value > 59) {
                            return '<span class="label label-primary">'+value+'</span>';
                        }
                        else {
                            return '<span class="label label-warning-light">'+value+'</span>';
                        }
                    }
                },
                {
                    field: 'rating',
                    title: '评级',
                    formatter: function(value, row, index) {
                       return $.table.selectDictLabel(ratingDatas, value);
                    }
                },
                {
                    field: 'filePath',
                    title: '附件地址',
                    visible: false
                },
                {
                    field: 'status',
                    title: '状态',
                    visible: false
                },
                {
                    field: 'createTime',
                    title: '创建时间'
                },
                {
                    title: '操作',
                    align: 'center',
                    formatter: function(value, row, index) {
                        var actions = [];
                        actions.push('<a class="btn btn-default btn-xs ' + editFlag + '" href="javascript:void(0)" onclick="$.operate.detail(\'' + row.taskResuletId + '\')"><i class="fa fa-info-circle"></i>查看</a> ');
                        // actions.push('<a class="btn btn-danger btn-xs ' + removeFlag + '" href="javascript:void(0)" onclick="$.operate.remove(\'' + row.taskResuletId + '\')"><i class="fa fa-remove"></i>删除</a>');
                        return actions.join('');
                    }
                }]
            };
            $.table.init(options);
        });
    </script>
</body>
</html>
